#include "../main/lvgl_task.h"
#include "lv_timer.h"
#include "lvgl.h"
#include "./demos/lv_demos.h"
#include "sound_spectrogram.h"

extern const uint8_t xrlkj_map[];
extern const lv_image_dsc_t xrlkj[];
extern const unsigned char renesas_logo[];

void lvgl_task_init(void)
{
    uint16_t * p_fb = (uint16_t *)&fb_background[0][0];
    uint16_t* src = (uint16_t*)xrlkj_map;
    uint32_t x, y;

#if (1 == LV_USE_DEMO_BENCHMARK)
        lv_demo_benchmark();
    #endif

    #if (1 == LV_USE_DEMO_MUSIC)
        lv_demo_music();
    #endif

    #if (1 == LV_USE_DEMO_KEYPAD_AND_ENCODER)
        lv_demo_keypad_encoder();

    #endif

    #if (1 == LV_USE_DEMO_STRESS)
        lv_demo_stress();
    #endif

    #if (1 == LV_USE_DEMO_WIDGETS && 0 == LV_USE_DEMO_BENCHMARK)
//        lv_demo_widgets();
    #endif

        for (x = 0; x < 224; x++)
        {
            for (y = 0; y < 480; y++)
            {
                p_fb[y + x * 480] = src[x * 480 + y];
            }
        }

        R_GLCDC_BufferChange (&g_lvgl_port_ctrl, (uint8_t*) p_fb, DISPLAY_FRAME_LAYER_1);

        R_BSP_SoftwareDelay(5000,1000);

        //lv_demo_widgets();

        sound_spectrogram_create_ui();


}

void lvgl_task(void)
{
    lv_timer_handler();
}
